1 // DerelictCL - a Derelict based dynamic binding for OpenCL
2 // written in the D programming language
3 //
4 // Copyright: MeinMein 2013-2014.
5 // License:   Boost License 1.0
6 //            (See accompanying file LICENSE_1_0.txt or copy at
7 //             http://www.boost.org/LICENSE_1_0.txt)
8 // Authors:   Gerbrand Kamphuis (meinmein.com),
9 //            Marvin Meeng (meinmein.com).
10 module derelict.opencl.types;
11 
12 // cl_platform.h
13 alias byte      cl_char;
14 alias ubyte     cl_uchar;
15 alias short     cl_short;
16 alias ushort    cl_ushort;
17 alias int       cl_int;
18 alias uint      cl_uint;
19 alias long      cl_long;    // cl_long and cl_ulong are really intended as 64-bit integers
20 alias ulong     cl_ulong;   // so no need to use core.stdc.config.c_long/c_ulong
21 
22 alias ushort    cl_half;
23 alias float     cl_float;
24 alias double    cl_double;
25 
26 alias uint      cl_GLuint;
27 alias int       cl_GLint;
28 alias uint      cl_GLenum;
29 
30 // cl.h
31 alias void*     cl_platform_id;
32 alias void*     cl_device_id;
33 alias void*     cl_context;
34 alias void*     cl_command_queue;
35 alias void*     cl_mem;
36 alias void*     cl_program;
37 alias void*     cl_kernel;
38 alias void*     cl_event;
39 alias void*     cl_sampler;
40 
41 alias cl_uint           cl_bool;                     /* WARNING!  Unlike cl_ types in cl_platform.h, cl_bool is not guaranteed to be the same size as the bool in kernels. */
42 alias cl_ulong          cl_bitfield;
43 alias cl_bitfield       cl_device_type;
44 alias cl_uint           cl_platform_info;
45 alias cl_uint           cl_device_info;
46 alias cl_bitfield       cl_device_fp_config;
47 alias cl_uint           cl_device_mem_cache_type;
48 alias cl_uint           cl_device_local_mem_type;
49 alias cl_bitfield       cl_device_exec_capabilities;
50 alias cl_bitfield       cl_command_queue_properties;
51 alias ptrdiff_t         cl_device_partition_property;
52 alias cl_bitfield       cl_device_affinity_domain;
53 
54 alias ptrdiff_t         cl_context_properties;
55 alias cl_uint           cl_context_info;
56 alias cl_uint           cl_command_queue_info;
57 alias cl_uint           cl_channel_order;
58 alias cl_uint           cl_channel_type;
59 alias cl_bitfield       cl_mem_flags;
60 alias cl_uint           cl_mem_object_type;
61 alias cl_uint           cl_mem_info;
62 alias cl_bitfield       cl_mem_migration_flags;
63 alias cl_uint           cl_image_info;
64 alias cl_uint           cl_buffer_create_type;
65 alias cl_uint           cl_addressing_mode;
66 alias cl_uint           cl_filter_mode;
67 alias cl_uint           cl_sampler_info;
68 alias cl_bitfield       cl_map_flags;
69 alias cl_uint           cl_program_info;
70 alias cl_uint           cl_program_build_info;
71 alias cl_uint           cl_program_binary_type;
72 alias cl_int            cl_build_status;
73 alias cl_uint           cl_kernel_info;
74 alias cl_uint           cl_kernel_arg_info;
75 alias cl_uint           cl_kernel_arg_address_qualifier;
76 alias cl_uint           cl_kernel_arg_access_qualifier;
77 alias cl_bitfield       cl_kernel_arg_type_qualifier;
78 alias cl_uint           cl_kernel_work_group_info;
79 alias cl_uint           cl_event_info;
80 alias cl_uint           cl_command_type;
81 alias cl_uint           cl_profiling_info;
82 
83 struct cl_image_format
84 {
85     cl_channel_order    image_channel_order;
86     cl_channel_type     image_channel_data_type;
87 }
88 
89 struct cl_image_desc
90 {
91     cl_mem_object_type  image_type;
92     size_t              image_width;
93     size_t              image_height;
94     size_t              image_depth;
95     size_t              image_array_size;
96     size_t              image_row_pitch;
97     size_t              image_slice_pitch;
98     cl_uint             num_mip_levels;
99     cl_uint             num_samples;
100     cl_mem              buffer;
101 }
102 
103 struct cl_buffer_region
104 {
105     size_t              origin;
106     size_t              size;
107 }
108 
109 // cl_ext.h
110 alias cl_ulong          cl_device_partition_property_ext;
111 
112 // cl_egl.h
113 alias void*             CLeglImageKHR;
114 alias void*             CLeglDisplayKHR;
115 alias ptrdiff_t         cl_egl_image_properties_khr;
116 
117 // cl_gl.h
118 alias cl_uint           cl_gl_object_type;
119 alias cl_uint           cl_gl_texture_info;
120 alias cl_uint           cl_gl_platform_info;
121 
122 struct __GLsync;
123 alias __GLsync*         cl_GLsync;
124 
125 alias cl_uint           cl_gl_context_info;
126 
127 // cl_d3d10.h
128 alias void              ID3D10Buffer;
129 alias void              ID3D10Texture2D;
130 alias void              ID3D10Texture3D;
131 
132 alias cl_uint           cl_d3d10_device_source_khr;
133 alias cl_uint           cl_d3d10_device_set_khr;
134 
135 // cl_d3d11.h
136 alias void              ID3D11Buffer;
137 alias void              ID3D11Texture2D;
138 alias void              ID3D11Texture3D;
139 
140 alias cl_uint           cl_d3d11_device_source_khr;
141 alias cl_uint           cl_d3d11_device_set_khr;
142 
143 // cl_dx9_media_sharing.h
144 alias cl_uint           cl_dx9_media_adapter_type_khr;
145 alias cl_uint           cl_dx9_media_adapter_set_khr;
146 
147 version(Windows)
148 {
149     alias void          IDirect3DSurface9;
150     alias void*         HANDLE;
151 
152     struct cl_dx9_surface_info_khr
153     {
154         IDirect3DSurface9*  resource;
155         HANDLE              shared_handle;
156     }
157 }
158 
159 // This is a Derelict type, not from OpenCL
160 enum CLVersion
161 {
162     None,
163     CL10 = 10,
164     CL11 = 11,
165     CL12 = 12,
166     HighestSupported = CL12,
167 }